/**
 * @a https://leetcode.cn/problems/integer-to-roman/description/
 */

#incluede "common.h"

const pair<int, string> value2Roman[] = {
    {1000, "M"}, {900, "CM"}, {500, "D"}, {400, "CD"},
    {100, "C"}, {90, "XC"},  {50, "L"},   {40, "XL"},
    {10, "X"},   {9, "IX"}, {5, "V"},{4, "IV"},
    {1, "I"}
};
class Solution {
public:
    string intToRoman(int num) {
        string roman;
        for(auto &[value, symbol] : value2Roman){
            while(num >= value){
                num -= value;
                roman += symbol;
            }
            if(num == 0) break;
        }
        return roman;
    }
};
